Page({
  data: {
    user:wx.getStorageSync('user'),
    reviews: [
     
    ]
  },

  delIt(e){
    const item = e.currentTarget.dataset.item
    if(item.userId!==wx.getStorageSync('user').id){
      wx.showToast({
        title: '您无权操作！',
        icon:'none'
      })
      return 
    }
  
  wx.showModal({
    title: '提示',
    content: '是否删除当前评价？',
  
  }).then(async r=>{
    if(r.confirm){
await getApp().$request('/api/delDogCmt','POST',{id:item.id})
wx.showToast({
  title: '删除成功',
})
this.getList()
    }
  })
  },

  inputIt(e){
this.data.content = e.detail.value

  },
 async  cmtIt(){
  if(!this.data.content){
    wx.showToast({
      title: '请输入内容',
      icon:"none"
    })
    return 
  }
  const res  = await getApp().$request('/api/dogCmtIt','POST',{dogId:this.data.dogId,userId:this.data.user.id,content:this.data.content})
 wx.showToast({
   title: '评价成功',
 })
 this.setData({
   content:''
 })
 this.getList()
},
  onLoad(options){
    this.data.dogId = options.dogId
    this.getList()
  },
  async getList(){
const res  = await getApp().$request('/api/getDogCmtList','POST',{dogId:this.data.dogId})
this.setData({
  reviews:res.data
})
  },
});
